package com.offcn.data.service.impl;


import com.offcn.bean.CategroyTop;
import com.offcn.bean.DataBean;
import com.offcn.categroy.dao.CategroyDao;
import com.offcn.categroytop.dao.CategroyTopDao;
import com.offcn.data.service.DataService;
import com.offcn.movie.dao.MovieDao;
import com.offcn.perform.dao.PerformerDao;
import com.offcn.user.dao.UserDao;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class DataServiceImpl implements DataService {
    @Resource
    private MovieDao movieDao;
    @Resource
    private PerformerDao performerDao;
    @Resource
    private UserDao userDao;
    @Resource
    private CategroyDao categroyDao;
    @Resource
    private CategroyTopDao categroyTopDao;

    @Override
    public DataBean queryData() {
        int movienum = movieDao.countMovie();
        int perforernum = performerDao.countPerformer();
        int usernum = userDao.countUser();
        int categroynum = categroyDao.countCategroy();

        DataBean dataBean = new DataBean();
        //电影总数
        dataBean.setMovienum(movienum);
        //演员总数
        dataBean.setPerfomernum(perforernum);
        //用户总数
        dataBean.setUsernum(usernum);
        //分类总数
        dataBean.setCategroynum(categroynum);

        //分类占比统计
        List<CategroyTop> tops = categroyTopDao.selectTop();
        dataBean.setTops(tops);

        return dataBean;
    }

}
